package com.desay.pangoo.itmt.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import lombok.Data;

/**
 * @author uidq1163 on [2023年01月04日上午10:16:03] <br>
 *         产品平台，BU对应关系
 * @Modified By： [修改人] on [修改日期] for [修改说明]
 */
@Entity
@EntityListeners(AuditingEntityListener.class)
@Table(name = "product_platform_bu")
@Data
public class ProjectBUEntity extends BaseEntity implements Serializable {

	private static final long serialVersionUID = -3161217180941112174L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "id", columnDefinition = "bigint COMMENT '主键'")
	private Long id;

	@Column(name = "product_platform", nullable = false, columnDefinition = "varchar(255) COMMENT '产品平台'")
	private String productPlatform;
	
	@Column(name = "platform", nullable = false, columnDefinition = "varchar(255) COMMENT '产品分类'")
	private String platform;
	
	@Column(name = "platform_classification", nullable = true, columnDefinition = "varchar(255) COMMENT '平台'")
	private String platformClassification;

	/** 应用平台 */
	@ManyToMany
	@JoinTable(name = "ref_project_platform_bu_div", joinColumns = {
			@JoinColumn(name = "project_bu_id") }, inverseJoinColumns = { @JoinColumn(name = "div_id") }, uniqueConstraints = {
					@UniqueConstraint(columnNames = { "project_bu_id", "div_id" }) })
	private Set<BUDivEntity> bus;

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		ProjectBUEntity other = (ProjectBUEntity) obj;
		if (id == null) {
			if (other.id != null) {
				return false;
			}
		} else if (!id.equals(other.id)) {
			return false;
		}
		return true;
	}
}
